object PascalTri {
  def printTri(height: Int): Unit = {
    var lastLine = Array(1)
    if (height >= 1) println(lastLine.mkString("", " ", ""))
    if (height >= 2) {
      lastLine = Array(1, 1)
      println(lastLine.mkString("", " ", ""))
    }
    for (eleNum <- 3 to height) {
      val newLine = new Array[Int](eleNum)
      newLine(0) = 1; newLine(eleNum - 1) = 1
      for (i <- 1 until eleNum - 1) {
        newLine(i) = lastLine(i) + lastLine(i - 1)
      }
      lastLine = newLine
      println(lastLine.mkString("", " ", ""))
    }
  }

  def main(args: Array[String]): Unit = {
    printTri(10)
  }
}